package ossutils

import (
	"io"

	"github.com/aliyun/aliyun-oss-go-sdk/oss"
)

func UploadOss(image io.Reader, fileName string) (string, error) {

	endpoint := "oss-cn-guangzhou.aliyuncs.com"
	accessKeyId := "LTAI5tMRFZJX48VmsPsmkXRB"
	accessKeySecret := "AzMckDiRAEhQXK8kSDRX00xSmVThuc"
	bucketName := "fxswift"
	host := "fxswift.oss-cn-guangzhou.aliyuncs.com"

	client, err := oss.New(endpoint, accessKeyId, accessKeySecret)
	if err != nil {
		return "", err
	}
	bucket, _ := client.Bucket(bucketName)
	objectKey := fileName

	return host + "/" + objectKey, bucket.PutObject(objectKey, image)
}
